package com.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.constant.Constant;
import com.ry.st.driver.R;

public class PopAdapter extends BaseAdapter {
	public String[] list;
	public LayoutInflater inflater;
	public Context context;
	private int lastItem = Constant.popSelItem;

	public int getLastItem() {
		return lastItem;
	}

	public void setLastItem(int lastItem) {
		this.lastItem = lastItem;
	}

	public PopAdapter(Context c, String[] list) {
		this.context = c;
		this.list = list;
		inflater = LayoutInflater.from(c);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.length;
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list[arg0];
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int arg0, View convertView, ViewGroup arg2) {
		// TODO Auto-generated method stub

		TextView t = (TextView) inflater.inflate(R.layout.pop_item, null);
		if (lastItem == arg0) {
			t.setBackgroundResource(R.drawable.ump_btn_bg_on);
		} else {
			t.setBackgroundResource(R.drawable.ump_btn_bg_normal);
		}
		t.setText(list[arg0]);
		return t;
	}

}
